<?php
class QuinielasController extends AppController {
	var $name = 'Quinielas';
	var $uses = array('Partido','Quiniela');
	var $condiciones = '';
	var $aux = '';
	var $scaffold;
	
	function index() {
		$this->set('temporada',2008);
		$this->set('jornada', 9);
		$condiciones = 'temporada =2008';
		$this->set('quinielas',$this->Quiniela->findAll($condiciones,NULL,'jornada ASC',5));
		if ($this->Session->read('Usuario') AND $this->Session->read('Usuario.id') == 0)
			{
				$this->set('activeADMIN','adminON');
			}
		else
			{
				$this->set('activeADMIN','adminOFF');
			}
	}
	
	function hacer() {
		$this->checkSession();
		$condiciones = 'temporada = 2008 AND jornada = 9';
		$this->set('quinielas',$this->Quiniela->findAll($condiciones));
		print_r($this->Quiniela->findAll($condiciones));
		$aux = '';
		if (!empty($this->data))
		{
			foreach ($this->data['Quiniela']['pronostico'] as $pronostico):
			$aux = $aux.$pronostico;
			endforeach;
			$this->data['Quiniela']['pronostico'] = $aux;

			if ($this->Quiniela->save($this->data))
			{
				$this->flash('La quiniela ha sido registrada.','/quinielas');
			}
		}
	}
}
?>

